<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div></div>
    <script>
        const div = document.querySelector("div")
        // 鼠标经过
        div.addEventListener("mouseenter", function () {
            console.log("我进来了")
        })
        // 鼠标离开
        div.addEventListener("mouseleave", function () {
            console.log("我走了")
        })
    </script>
</body>
</html>